package com.aiss.ws.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aiss.ws.Entity.CurseItem;
import com.aiss.ws.R;

import java.util.List;

/**
 * Created by chenqiang
 */
public class HomeAdatper extends BaseAdapter {

    private List<CurseItem> datas;
    private Context context;

    public HomeAdatper(List<CurseItem> datas,Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(convertView==null){
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.home_item, null);
            holder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);
            convertView.setTag(holder);
        }else{
            holder = (Holder) convertView.getTag();
        }

        holder.name_tv.setText(datas.get(position).getNamex());



        return convertView;
    }

    class Holder{

        TextView name_tv;

    }

}
